package sjq.com.title.refresh;

import android.annotation.TargetApi;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import sjq.com.title.R;
import sjq.com.title.ScreenUtils;


/**
 * Created by 何川 on 2016/7/21 0004.
 */
public class MyfootView extends LinearLayout {
    TextView tv ;
    ProgressBar progress;

    public MyfootView(Context context) {
        super(context);
        init();
    }

    public MyfootView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }
    @TargetApi(11)
    public MyfootView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }
    @TargetApi(21)
    public MyfootView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init();
    }

    private void init(){
        View view = inflate(getContext(), R.layout.refresh_foot,null);
        view.setLayoutParams(new LayoutParams(ScreenUtils.getScreenWidth(getContext()), ViewGroup.LayoutParams.WRAP_CONTENT));
        removeAllViews();
        addView(view);
        tv = (TextView) view.findViewById(R.id.tv_text);
        progress = (ProgressBar) view.findViewById(R.id.progressbar);
    }

    public void OnLoadOver(){
        tv.setText("加载完成");
        progress.setVisibility(View.GONE);
    }
    public void OnLoading(){
        tv.setText("加载更多");
        progress.setVisibility(View.VISIBLE);
    }


}
